type system cleanup
authorØyvind Kolås <ok@src.gnome.org>
Wed, 10 Aug 2005 14:30:49 +0000 (14:30 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Wed, 10 Aug 2005 14:30:49 +0000 (14:30 +0000)
18 files changed:
ChangeLog
babl/Makefile-mini
babl/babl-classes.c
babl/babl-classes.h
babl/babl-component.c
babl/babl-conversion.c
babl/babl-db.h
babl/babl-fish.c
babl/babl-format.c
babl/babl-image.c
babl/babl-internal.c
babl/babl-introspect.c
babl/babl-model.c
babl/babl-pixel-format.c
babl/babl-sampling.c
babl/babl-sanity.c
babl/babl-type.c
tests/Makefile.am

index 309605fd643c1084dbe490ea13578a5cf1e57bb1..738bd36bfce06ef1afd9283ad1f0b2de082c0b2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,29 @@
-2005-09-09  Øyvind Kolås  <pippin@gimp.org>
+2005-08-09  Øyvind Kolås  <pippin@gimp.org>
+
+       * babl/Makefile-mini: CFLAGS = -Werror -Wall ....
+       * babl/babl-classes.[ch]: BablPixelFormat removed unused pointers
+       to lists of conversions. Added BablReferenceFish. Renamed kind/
+       instance.type to class_type/instance.class_type. Removed mostly
+       unused macro's and expanded them in source
+
+       * babl/babl-component.c
+       * babl/babl-conversion.c
+       * babl/babl-db.h
+       * babl/babl-fish.c
+       * babl/babl-image.c
+       * babl/babl-introspect.c
+       * babl/babl-model.c
+       * babl/babl-pixel-format.c
+       * babl/babl-sampling.c
+
+       * babl/babl-type.c: removed switch statement since all enums are
+       handled equally.
+
+       * babl/tests/Makefile.am: added nop and introspect to TESTS, not
+       actual tests yet, but at least a segfault will cause make check to
+       fail.
+       
+2005-08-09  Øyvind Kolås  <pippin@gimp.org>
 
        * autogen.sh: make autogen also run make
        * babl/babl-classes.h: added define macro usable for sampling and
        * babl/babl-fish.[ch]: cleanup of stub class
        * babl/babl-sampling.h: simplification of header using a define.
 
-2005-09-09  Øyvind Kolås  <pippin@gimp.org>
+2005-08-09  Øyvind Kolås  <pippin@gimp.org>
 
        * babl/babl-conversion.c: indentation cleanup.
 
-2005-09-09  Øyvind Kolås  <pippin@gimp.org>
+2005-08-09  Øyvind Kolås  <pippin@gimp.org>
 
        * babl/babl-ids: added BABL_LUMINANCE_GAMMA_2_2,
        BABL_LUMINANCE_MUL_ALPHA, BABL_GRAYSCALE_GAMMA_2_2,
index ae4f71aa383a94a81523bc1fe8ab51a2abfbf73c..ea1d7fb6dc4a62d16aada98509597ab59ade5b8a 100644 (file)
@@ -1,13 +1,14 @@
 # This makeile is used for more rapid test compilations than
 # autofoo allows, it will not build a usable libray though.
 
-default: clean all
 
 TARGETS =                              \
        ../tests/nop                    \
        ../tests/introspect
 
-CFLAGS = -Wall -g -O1 -I./babl-base  -I. -I..
+default: $(TARGETS)
+
+CFLAGS = -Wall -Werror -g -O1 -I./babl-base  -I. -I..
 
 BABL_OBJECTS=                                  \
        babl.o                                  \
index f39350a5609800dcbb0e1bb48c989eeacf47d304..0d2e0285c7c0505e08491da4c93bcdcf7c4da558 100644 (file)
@@ -34,6 +34,8 @@ static const char *class_names[] =
     "BablConversionPixelFormatPlanar",
     "BablConversionPixelFormatPlanar",
     "BablFish",
+    "BablReferenceFish",
+    "BablImage",
     "BablCeiling"
   };
 
index 3b9fffeed0a1f9f626ecc6e1bdd059d3cd883633..6d69ea3a74bd25f998c1cf653ad9e93fbbb96b6b 100644 (file)
@@ -62,6 +62,7 @@ typedef enum {
   BABL_CONVERSION_PIXEL_FORMAT_PLANAR,
 
   BABL_FISH,
+  BABL_FISH_REFERENCE,
   BABL_IMAGE,
 
   BABL_SKY
@@ -73,7 +74,7 @@ typedef enum {
 /* common header for any item inserted into database */
 typedef struct
 {
-  BablClassType  type;
+  BablClassType  class_type;
   int            id;      /*< a numerical id, look at 'babl-ids.h' for the reserved
                               ones */
   char          *name;    /*< the name this type exists under         */
@@ -167,8 +168,6 @@ typedef struct
   BablComponent  **component;
   BablType       **type;
   BablSampling   **sampling;
-  BablConversion  *to_conversions;
-  BablConversion  *from_conversions;
 } BablPixelFormat;
 
 typedef struct
@@ -188,35 +187,33 @@ typedef struct
   union Babl      *destination;
 } BablFish;
 
+typedef struct
+{
+  BablFish         fish;
+  BablConversion  *type_to_double;
+  BablConversion  *model_to_rgba;
+  BablConversion  *rgba_to_model;
+  BablConversion  *double_to_type;
+} BablReferenceFish;
+
 typedef union
 {
-  BablClassType   kind;
-  BablInstance    instance;
-  BablType        type;
-  BablSampling    sampling;
-  BablComponent   component;
-  BablModel       model;
-  BablPixelFormat pixel_format;
-  BablConversion  conversion;
-  BablFish        fish;
-  BablImage        image;
+  BablClassType     class_type;
+  BablInstance      instance;
+  BablType          type;
+  BablSampling      sampling;
+  BablComponent     component;
+  BablModel         model;
+  BablPixelFormat   pixel_format;
+  BablConversion    conversion;
+  BablFish          fish;
+  BablReferenceFish reference_fish;
+  BablImage         image;
 } Babl;
 
 
-#define BABL_NAME(obj)          (((Babl*)(obj))->instance.name)
-#define BABL_INSTANCE_TYPE(obj) (((Babl*)(obj))->kind)
-
 #define BABL_IS_BABL(obj)\
-(NULL==(obj)?0:BABL_CLASS_TYPE_IS_VALID(BABL_INSTANCE_TYPE(obj)))
-
-#define BABL_IS_OF_KIND(obj,kind) \
-    (!BABL_IS_BABL(obj)?0:kind==BABL_INSTANCE_TYPE(obj)?1:0)
-
-#define BABL_IS_INSTANCE(obj)      BABL_IS_OF_KIND(obj,BABL_TYPE)
-#define BABL_IS_TYPE(obj)          BABL_IS_OF_KIND(obj,BABL_TYPE)
-#define BABL_IS_COMPONENT(obj)     BABL_IS_OF_KIND(obj,BABL_COMPONENT)
-#define BABL_IS_SAMPLING(obj)      BABL_IS_OF_KIND(obj,BABL_SAMPLING)
-#define BABL_IS_PIXEL_FORMAT(obj)  BABL_IS_OF_KIND(obj,BABL_PIXEL_FORMAT)
+(NULL==(obj)?0:BABL_CLASS_TYPE_IS_VALID(((Babl*)(obj))->class_type))
 
 typedef int  (*BablEachFunction) (Babl *entry,
                                   void *data);
index f4180e272ad82160c06cb6b0d4b058b79db84c17..a591f8e698dd5d38e7f0a0f3ca2c76b743cd9ea8 100644 (file)
@@ -42,17 +42,17 @@ component_new (const char *name,
                int         chroma,
                int         alpha)
 {
-  BablComponent *self;
+  Babl *self;
 
-  self                = babl_calloc (sizeof (BablComponent), 1);
-  self->instance.type = BABL_COMPONENT;
-  self->instance.id   = id;
-  self->instance.name = babl_strdup (name);
-  self->luma       = luma;
-  self->chroma     = chroma;
-  self->alpha      = alpha;
+  self                   = babl_calloc (sizeof (BablComponent), 1);
+  self->class_type       = BABL_COMPONENT;
+  self->instance.id      = id;
+  self->instance.name    = babl_strdup (name);
+  self->component.luma   = luma;
+  self->component.chroma = chroma;
+  self->component.alpha  = alpha;
 
-  return self;
+  return (BablComponent*) self;
 }
 
 BablComponent *
@@ -79,7 +79,7 @@ babl_component_new (const char *name,
         {
           Babl *babl = (Babl*)arg;
 
-          switch (BABL_INSTANCE_TYPE (arg))
+          switch (babl->class_type)
             {
               case BABL_TYPE:
               case BABL_INSTANCE:
@@ -95,9 +95,10 @@ babl_component_new (const char *name,
               case BABL_CONVERSION_PIXEL_FORMAT:
               case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
               case BABL_FISH:
+              case BABL_FISH_REFERENCE:
               case BABL_IMAGE:
                 babl_log ("%s(): %s unexpected",
-                          __FUNCTION__, babl_class_name (babl->instance.type));
+                          __FUNCTION__, babl_class_name (babl->class_type));
                 break;
               case BABL_SKY: /* shut up compiler */
                 break;
index 21cb7462675fdad19ed3bf22a754ad46859eeee8..f2385ff4486a4b9241dd4500baf31a69597bdefc 100644 (file)
@@ -43,23 +43,23 @@ conversion_new (const char        *name,
                 BablFuncPlanar     planar,
                 BablFuncPlanarBit  planar_bit)
 {
-  BablConversion *self = NULL;
+  Babl *self = NULL;
 
   /* destination is of same type as source */ 
-  switch (BABL_INSTANCE_TYPE (source))
+  switch (source->class_type)
     {
       case BABL_TYPE:
         if (linear)
           {
             self = babl_calloc (sizeof (BablConversionType), 1);
-            self->instance.type = BABL_CONVERSION_TYPE;
-            self->function.linear = linear;
+            self->class_type      = BABL_CONVERSION_TYPE;
+            self->conversion.function.linear = linear;
           }
         else if (planar)
           {
             self = babl_calloc (sizeof (BablConversionTypePlanar), 1);
-            self->instance.type = BABL_CONVERSION_TYPE_PLANAR;
-            self->function.planar = planar;
+            self->class_type = BABL_CONVERSION_TYPE_PLANAR;
+            self->conversion.function.planar = planar;
           }
         else if (planar_bit)
           {
@@ -84,8 +84,8 @@ conversion_new (const char        *name,
         else if (planar)
           {
             self = babl_calloc (sizeof (BablConversionModelPlanar), 1);
-            self->instance.type = BABL_CONVERSION_MODEL_PLANAR;
-            self->function.planar = planar;
+            self->class_type = BABL_CONVERSION_MODEL_PLANAR;
+            self->conversion.function.planar = planar;
           }
         else if (planar_bit)
           {
@@ -98,14 +98,14 @@ conversion_new (const char        *name,
         if (linear)
           {
             self = babl_calloc (sizeof (BablConversionPixelFormat), 1);
-            self->instance.type = BABL_CONVERSION_PIXEL_FORMAT;
-            self->function.linear = linear;
+            self->class_type = BABL_CONVERSION_PIXEL_FORMAT;
+            self->conversion.function.linear = linear;
           }
         else if (planar)
           {
             self = babl_calloc (sizeof (BablConversionPixelFormatPlanar), 1);
-            self->instance.type = BABL_CONVERSION_PIXEL_FORMAT_PLANAR;
-            self->function.planar = planar;
+            self->class_type = BABL_CONVERSION_PIXEL_FORMAT_PLANAR;
+            self->conversion.function.planar = planar;
           }
         else if (planar_bit)
           {
@@ -122,12 +122,12 @@ conversion_new (const char        *name,
       return NULL;
     }
 
-  self->instance.id   = id;
-  self->instance.name = babl_strdup (name);
-  self->source        = (union Babl*)source;
-  self->destination   = (union Babl*)destination;
-  self->time_cost     = time_cost;
-  self->loss          = loss;
+  self->instance.id            = id;
+  self->instance.name          = babl_strdup (name);
+  self->conversion.source      = (union Babl*)source;
+  self->conversion.destination = (union Babl*)destination;
+  self->conversion.time_cost   = time_cost;
+  self->conversion.loss        = loss;
 
   babl_add_ptr_to_list ((void ***)&(source->type.from), self);
   babl_add_ptr_to_list ((void ***)&(destination->type.to), self);
index 7b4b7e51a493efa171316600ce8e3c35f57998e4..204a5bb4b63dc2c1b2ec073b93922ddb9010e8bd 100644 (file)
@@ -56,7 +56,7 @@ DB_DEF Babl * db_find    (const char *name)
       const char *sample_type = "unknwon";
 
       if (db[0])
-        sample_type = babl_class_name (db[0]->instance.type);
+        sample_type = babl_class_name (db[0]->class_type);
       babl_log ("%s(\"%s\"): failed (query performed on a %s database)",
        __FUNCTION__, name, sample_type);
     }
index b0a3a30825d372d8ad9214868cf98351025b54d1..e4be9d89ad05e0c27d726f0c21142d5ff785c670 100644 (file)
@@ -36,26 +36,25 @@ babl_fish_new (const char        *name,
                Babl              *source,
                Babl              *destination)
 {
-  BablFish *self = NULL;
+  Babl *self = NULL;
 
-  self = babl_calloc (sizeof (BablFish), 1);
-  self->instance.type = BABL_FISH;
+  assert (BABL_IS_BABL (source));
+  assert (BABL_IS_BABL (destination));
 
-  self->instance.id   = 0;
-  self->instance.name = "Fishy";
-  self->source        = (union Babl*)source;
-  self->destination   = (union Babl*)destination;
+  self                   = babl_calloc (sizeof (BablFish), 1);
+  self->class_type             = BABL_FISH;
+  self->instance.id      = 0;
+  self->instance.name    = "Fishy";
+  self->fish.source      = (union Babl*)source;
+  self->fish.destination = (union Babl*)destination;
 
-  assert (BABL_IS_BABL (self->source));
-  assert (BABL_IS_BABL (self->destination));
-
-  if ((BablFish*) db_insert ( (Babl*)self) == self)
+  if (db_insert (self) == self)
     {
-      return self;
+      return (BablFish*)self;
     }
   else
     {
-      each_babl_fish_destroy ( (Babl*)self, NULL);
+      each_babl_fish_destroy (self, NULL);
       return NULL;
     }
 
index 226125cecba6e00da60a78bf1a900dac3befee94..c84536cc4917f05a758746fe2a9f0573713c4dcf 100644 (file)
@@ -52,33 +52,33 @@ pixel_format_new (const char     *name,
                   BablSampling  **band_sampling,
                   BablType      **band_type)
 {
-  BablPixelFormat *self;
+  Babl *self;
   int              band;
 
   self                     = babl_calloc (sizeof (BablPixelFormat), 1);
 
-  self->instance.type = BABL_PIXEL_FORMAT;
+  self->class_type    = BABL_PIXEL_FORMAT;
   self->instance.id   = id;
   self->instance.name = babl_strdup (name);
 
-  self->bands         = bands;
-  self->planar        = planar;
+  self->pixel_format.bands    = bands;
+  self->pixel_format.planar   = planar;
 
-  self->component     = babl_malloc (sizeof (BablComponent*) * (bands+1));
-  self->type          = babl_malloc (sizeof (BablType*)      * (bands+1));
-  self->sampling      = babl_malloc (sizeof (BablSampling*)  * (bands+1));
+  self->pixel_format.component = babl_malloc (sizeof (BablComponent*) * (bands+1));
+  self->pixel_format.type     = babl_malloc (sizeof (BablType*)      * (bands+1));
+  self->pixel_format.sampling = babl_malloc (sizeof (BablSampling*)  * (bands+1));
 
   for (band=0; band < bands; band++)
     {
-      self->component[band] = band_component[band];
-      self->type[band] = band_type[band];
-      self->sampling[band] = band_sampling[band];
+      self->pixel_format.component[band] = band_component[band];
+      self->pixel_format.type[band] = band_type[band];
+      self->pixel_format.sampling[band] = band_sampling[band];
     }
-  self->component[band] = NULL;
-  self->type[band]      = NULL;
-  self->sampling[band]  = NULL;
+  self->pixel_format.component[band] = NULL;
+  self->pixel_format.type[band]      = NULL;
+  self->pixel_format.sampling[band]  = NULL;
 
-  return self;
+  return (BablPixelFormat*)self;
 }
 
 BablPixelFormat *
@@ -112,7 +112,7 @@ babl_pixel_format_new (const char *name,
         {
           Babl *babl = (Babl*)arg;
 
-          switch (BABL_INSTANCE_TYPE (arg))
+          switch (babl->class_type)
             {
               case BABL_TYPE:
                 current_type = (BablType*) babl;
@@ -135,7 +135,7 @@ babl_pixel_format_new (const char *name,
               case BABL_INSTANCE:
               case BABL_MODEL:
                 babl_log ("%s(): %s not handled in pixel format yet",
-                          __FUNCTION__, babl_class_name (babl->instance.type));
+                          __FUNCTION__, babl_class_name (babl->class_type));
                   break;
               case BABL_PIXEL_FORMAT:
 
@@ -146,9 +146,10 @@ babl_pixel_format_new (const char *name,
               case BABL_CONVERSION_PIXEL_FORMAT:
               case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
               case BABL_FISH:
+              case BABL_FISH_REFERENCE:
               case BABL_IMAGE:
                 babl_log ("%s(): %s unexpected",
-                          __FUNCTION__, babl_class_name (babl->instance.type));
+                          __FUNCTION__, babl_class_name (babl->class_type));
                 break;
               case BABL_SKY: /* shut up compiler */
                 break;
index 3edc9622dc574a0cc037a15adbc68704d7f93b76..6f398c7a5862d13eca12406b44d49bb62aa44221 100644 (file)
@@ -50,35 +50,35 @@ image_new (int             bands,
            int            *pitch,
            int            *stride)
 {
-  BablImage *self;
+  Babl *self;
   int        band;
 
   self                = babl_calloc (sizeof (BablImage), 1);
 
-  self->instance.type = BABL_IMAGE;
+  self->class_type    = BABL_IMAGE;
   self->instance.id   = 0;
   self->instance.name = "babl image";
 
-  self->bands         = bands;
+  self->image.bands         = bands;
 
-  self->component     = babl_malloc (sizeof (BablComponent*) * (bands+1));
-  self->data          = babl_malloc (sizeof (void*)          * (bands+1));
-  self->pitch         = babl_malloc (sizeof (int)            * (bands+1));
-  self->stride        = babl_malloc (sizeof (int)            * (bands+1));
+  self->image.component     = babl_malloc (sizeof (BablComponent*) * (bands+1));
+  self->image.data          = babl_malloc (sizeof (void*)          * (bands+1));
+  self->image.pitch         = babl_malloc (sizeof (int)            * (bands+1));
+  self->image.stride        = babl_malloc (sizeof (int)            * (bands+1));
 
   for (band=0; band < bands; band++)
     {
-      self->component[band] = component[band];
-      self->data[band]      = data[band];
-      self->pitch[band]     = pitch[band];
-      self->stride[band]    = stride[band];
+      self->image.component[band] = component[band];
+      self->image.data[band]      = data[band];
+      self->image.pitch[band]     = pitch[band];
+      self->image.stride[band]    = stride[band];
     }
-  self->component[band] = NULL;
-  self->data[band]      = NULL;
-  self->pitch[band]     = 0;
-  self->stride[band]    = 0;
+  self->image.component[band] = NULL;
+  self->image.data[band]      = NULL;
+  self->image.pitch[band]     = 0;
+  self->image.stride[band]    = 0;
 
-  return self;
+  return (BablImage*) self;
 }
 
 BablImage *
@@ -107,14 +107,14 @@ babl_image_new (void *first,
         {
           Babl *babl = (Babl*)arg;
 
-          if (babl->instance.type == BABL_COMPONENT)
+          if (babl->class_type == BABL_COMPONENT)
             {
               new_component = (BablComponent *)babl;
             }
           else
             {
                 babl_log ("%s(): %s unexpected",
-                          __FUNCTION__, babl_class_name (babl->instance.type));
+                          __FUNCTION__, babl_class_name (babl->class_type));
                 return NULL;
             }
         }
index f39350a5609800dcbb0e1bb48c989eeacf47d304..0d2e0285c7c0505e08491da4c93bcdcf7c4da558 100644 (file)
@@ -34,6 +34,8 @@ static const char *class_names[] =
     "BablConversionPixelFormatPlanar",
     "BablConversionPixelFormatPlanar",
     "BablFish",
+    "BablReferenceFish",
+    "BablImage",
     "BablCeiling"
   };
 
index ca29cd962feedf3a4feca44a13eb9f28eaf7fbc4..6ab5b28809886548239e21eff9fc110c6db3441a 100644 (file)
@@ -113,7 +113,7 @@ model_introspect (Babl *babl)
   for (i=0; i< babl->model.components; i++)
     {
       babl_log ("\t\tindex[%i] = '%s'",
-                i, BABL_NAME (babl->model.component[i]));
+                i, ((Babl*)babl->model.component[i])->instance.name  );
     }
 }
 
@@ -144,8 +144,8 @@ pixel_format_introspect (Babl *babl)
   for (i=0; i< babl->pixel_format.bands; i++)
     {
       babl_log ("\t\tband[%i] type='%s' component='%s'",
-                i, BABL_NAME (babl->pixel_format.type[i]),
-                   BABL_NAME (babl->pixel_format.component[i]));
+                i,  ( (Babl*)(babl->pixel_format.type[i]     ))->instance.name,
+                    ( (Babl*)(babl->pixel_format.component[i]))->instance.name);
     }
 }
 
@@ -156,8 +156,8 @@ each_introspect (Babl *babl,
   babl_log ("\t'%s'\t%i\t%s",
    babl->instance.name,
    babl->instance.id,
-   babl_class_name (babl->instance.type));
-  switch (babl->instance.type)
+   babl_class_name (babl->class_type));
+  switch (babl->class_type)
     {
       case BABL_TYPE:
         type_introspect (babl);
index e1657aee85fb16dfbf65858e4e6d7160ef8116df..c95740929b6cdd7fc2f5cd78b647542af5aff497 100644 (file)
@@ -44,26 +44,24 @@ model_new (const char     *name,
            int             components,
            BablComponent **component)
 {
-  BablModel *self;
-  int        i; 
+  Babl *self;
+  int   i; 
 
   self                     = babl_calloc (sizeof (BablModel), 1);
 
-  self->instance.type = BABL_MODEL;
-  self->instance.id   = id;
-  self->instance.name = babl_strdup (name);
-
-  self->components    = components;
-
-  self->component     = babl_malloc (sizeof (BablComponent*) * (components+1));
+  self->class_type       = BABL_MODEL;
+  self->instance.id      = id;
+  self->instance.name    = babl_strdup (name);
+  self->model.components = components;
+  self->model.component  = babl_malloc (sizeof (BablComponent*) * (components+1));
 
   for (i=0; i < components; i++)
     {
-      self->component[i] = component[i];
+      self->model.component[i] = component[i];
     }
-  self->component[i] = NULL;
+  self->model.component[i] = NULL;
 
-  return self;
+  return (BablModel*)self;
 }
 
 BablModel *
@@ -91,7 +89,7 @@ babl_model_new (const char *name,
         {
           Babl *babl = (Babl*)arg;
 
-          switch (BABL_INSTANCE_TYPE (arg))
+          switch (babl->class_type)
             {
               case BABL_COMPONENT:
                 band_component [components] = (BablComponent*) babl;
@@ -119,9 +117,10 @@ babl_model_new (const char *name,
               case BABL_CONVERSION_PIXEL_FORMAT:
               case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
               case BABL_FISH:
+              case BABL_FISH_REFERENCE:
               case BABL_IMAGE:
                 babl_log ("%s(): %s unexpected",
-                          __FUNCTION__, babl_class_name (babl->instance.type));
+                          __FUNCTION__, babl_class_name (babl->class_type));
                 break;
               case BABL_SKY: /* shut up compiler */
                 break;
index 226125cecba6e00da60a78bf1a900dac3befee94..c84536cc4917f05a758746fe2a9f0573713c4dcf 100644 (file)
@@ -52,33 +52,33 @@ pixel_format_new (const char     *name,
                   BablSampling  **band_sampling,
                   BablType      **band_type)
 {
-  BablPixelFormat *self;
+  Babl *self;
   int              band;
 
   self                     = babl_calloc (sizeof (BablPixelFormat), 1);
 
-  self->instance.type = BABL_PIXEL_FORMAT;
+  self->class_type    = BABL_PIXEL_FORMAT;
   self->instance.id   = id;
   self->instance.name = babl_strdup (name);
 
-  self->bands         = bands;
-  self->planar        = planar;
+  self->pixel_format.bands    = bands;
+  self->pixel_format.planar   = planar;
 
-  self->component     = babl_malloc (sizeof (BablComponent*) * (bands+1));
-  self->type          = babl_malloc (sizeof (BablType*)      * (bands+1));
-  self->sampling      = babl_malloc (sizeof (BablSampling*)  * (bands+1));
+  self->pixel_format.component = babl_malloc (sizeof (BablComponent*) * (bands+1));
+  self->pixel_format.type     = babl_malloc (sizeof (BablType*)      * (bands+1));
+  self->pixel_format.sampling = babl_malloc (sizeof (BablSampling*)  * (bands+1));
 
   for (band=0; band < bands; band++)
     {
-      self->component[band] = band_component[band];
-      self->type[band] = band_type[band];
-      self->sampling[band] = band_sampling[band];
+      self->pixel_format.component[band] = band_component[band];
+      self->pixel_format.type[band] = band_type[band];
+      self->pixel_format.sampling[band] = band_sampling[band];
     }
-  self->component[band] = NULL;
-  self->type[band]      = NULL;
-  self->sampling[band]  = NULL;
+  self->pixel_format.component[band] = NULL;
+  self->pixel_format.type[band]      = NULL;
+  self->pixel_format.sampling[band]  = NULL;
 
-  return self;
+  return (BablPixelFormat*)self;
 }
 
 BablPixelFormat *
@@ -112,7 +112,7 @@ babl_pixel_format_new (const char *name,
         {
           Babl *babl = (Babl*)arg;
 
-          switch (BABL_INSTANCE_TYPE (arg))
+          switch (babl->class_type)
             {
               case BABL_TYPE:
                 current_type = (BablType*) babl;
@@ -135,7 +135,7 @@ babl_pixel_format_new (const char *name,
               case BABL_INSTANCE:
               case BABL_MODEL:
                 babl_log ("%s(): %s not handled in pixel format yet",
-                          __FUNCTION__, babl_class_name (babl->instance.type));
+                          __FUNCTION__, babl_class_name (babl->class_type));
                   break;
               case BABL_PIXEL_FORMAT:
 
@@ -146,9 +146,10 @@ babl_pixel_format_new (const char *name,
               case BABL_CONVERSION_PIXEL_FORMAT:
               case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
               case BABL_FISH:
+              case BABL_FISH_REFERENCE:
               case BABL_IMAGE:
                 babl_log ("%s(): %s unexpected",
-                          __FUNCTION__, babl_class_name (babl->instance.type));
+                          __FUNCTION__, babl_class_name (babl->class_type));
                 break;
               case BABL_SKY: /* shut up compiler */
                 break;
index 567f0c6a24695c48abccf2a99ee3227caf8c772e..7bd2f86d0afba3e24101e1bae5304eba09631a06 100644 (file)
@@ -85,7 +85,7 @@ babl_sampling_init (void)
     for (vertical=VERTICAL_MIN; vertical<=VERTICAL_MAX; vertical++)
       {
         int index= (vertical-VERTICAL_MIN) * VERTICAL_MAX + (horizontal - HORIZONTAL_MIN);
-        db[index].instance.type = BABL_SAMPLING;
+        db[index].instance.class_type = BABL_SAMPLING;
         db[index].instance.id = 0;
         db[index].instance.name = "Samplings have no name";
         db[index].horizontal = horizontal;
index 4075bda7afee521f5a5582f309e9b01685eed224..db58dc8f0d4d9f90fca58525f7e8cfbc2c9bb943 100644 (file)
@@ -141,7 +141,7 @@ id_sanity (Babl *babl,
   if (0 == babl->instance.id)
     {
       babl_log ("%s\t'%s' has id==0",
-        babl_class_name (babl->instance.type), babl->instance.name);
+        babl_class_name (babl->class_type), babl->instance.name);
     }
   return 0;
 }
index ba1ff8ee0cc90e8162d9f8013413daa202e76a81..211733d9236f42f9a883de3d1eb8c7fad17d8860 100644 (file)
@@ -20,7 +20,6 @@
 #include "babl-internal.h"
 #include "babl-db.h"
 
-
 #include <string.h>
 #include <stdarg.h>
 
@@ -41,15 +40,15 @@ type_new (const char  *name,
           int          id,
           int          bits)
 {
-  BablType *self;
+  Babl *self;
 
   self                = babl_calloc (sizeof (BablType), 1);
-  self->instance.type = BABL_TYPE;
+  self->class_type    = BABL_TYPE;
   self->instance.id   = id;
   self->instance.name = babl_strdup (name);
-  self->bits          = bits;
+  self->type.bits     = bits;
 
-  return self;
+  return (BablType*)self;
 }
 
 BablType *
@@ -75,28 +74,8 @@ babl_type_new (const char *name,
         {
           Babl *babl = (Babl*)arg;
 
-          switch (BABL_INSTANCE_TYPE (arg))
-            {
-              case BABL_TYPE:
-              case BABL_INSTANCE:
-              case BABL_COMPONENT:
-              case BABL_MODEL:
-              case BABL_PIXEL_FORMAT:
-              case BABL_SAMPLING:
-
-              case BABL_CONVERSION:
-              case BABL_CONVERSION_TYPE:
-              case BABL_CONVERSION_TYPE_PLANAR:
-              case BABL_CONVERSION_MODEL_PLANAR:
-              case BABL_CONVERSION_PIXEL_FORMAT:
-              case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
-              case BABL_FISH:
-                babl_log ("%s(): %s unexpected",
-                          __FUNCTION__, babl_class_name (babl->instance.type));
-                break;
-              case BABL_SKY: /* shut up compiler */
-                break;
-            }
+          babl_log ("%s(): %s unexpected",
+                    __FUNCTION__, babl_class_name (babl->class_type));
         }
       /* if we didn't point to a babl, we assume arguments to be strings */
       else if (!strcmp (arg, "id"))
index 3be1ce52014d31e75918ac6357f8d5d44aa0bf83..1ad19d8af7afc268ed987017ba0d2ee269dc87f8 100644 (file)
@@ -14,3 +14,5 @@ nop_LDADD = $(top_builddir)/babl/libbabl.la
 
 EXTRA_DIST=            \
        .cvsignore
+
+TESTS=nop introspect